<!DOCTYPE html>
<#assign f = JspTaglibs["http://www.casic304.cn/f"] />
<#assign dicSelect = JspTaglibs["http://www.casic304.cn/dicSelect"]/>
<#assign SourceDept = JspTaglibs["http://www.casic304.cn/SourceDept"]/>
<html>
<head>
    <meta charset="utf-8">
    <title>质量信得过职工管理信息列表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="${ctx}/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="${ctx}/qbdmsStatic/iconfont/iconfont.css"/>
    <link rel="stylesheet" href="${ctx}/qbdmsStatic/style/qbdms.css">
    <script type="text/javascript">
        var __ctx = "${ctx}";
    </script>
</head>
<body class="listBody">
<div class="qbdms-list">
    <div class="layui-table-view-body">
        <table id="wQbdTrustPeopleTable" lay-filter="wQbdTrustPeopleTable"></table>
    </div>
</div>
<!-- 列表头部工具栏 -->
<script type="text/html" id="wQbdTrustPeopleHeaderToolsBar">
    <div class="ccpui-enterSel">
        <div class="layui-btn-container">
            <@f.a alias="xzan_zlxdgzg302" css="layui-btn layui-btn-sm fillBtn" event="add">
                <span>新增</span>
            </@f.a>
            <@f.a alias="scan_zlxdgzg302" css="layui-btn layui-btn-sm" event="delete">
                <span>删除</span>
            </@f.a>
            <a class="layui-btn layui-btn-sm" lay-event="export">
                <span>导出</span>
            </a>
        </div>
        <form class="layui-form" action="" lay-filter="wQbdTrustPeopleQueryForm" >
            <div class="layui-form-body selch">
                <div class="table-top-filter layui-row">
                    <@SourceDept.dept css="layui-input filter-value "/>
                    <div class="qbdms-listForm">
                        <label class="layui-form-label">年度</label>
                        <div class="layui-input-block">
                            <input type="text" class="layui-input filter-value" name="Q_years_SL" id="Q_years_SL" placeholder="请输入" readonly/>
                        </div>
                    </div>
                    <div class="qbdms-listForm">
                        <label class="layui-form-label">季度</label>
                        <div class="layui-input-block">
                            <@dicSelect.dic name="Q_quarter_SL" nodeKey="jd" css="layui-input filter-value"/>
                        </div>
                    </div>
                    <div class="qbdms-listForm">
                        <label class="layui-form-label">单位</label>
                        <div class="layui-input-block">
                            <select id="companyCode" name="Q_companyCode_S" autocomplete="off"
                                    class="layui-input filter-value" lay-filter="companyCode"
                                    fieldname="companyCode">
                            </select>
                        </div>
                    </div>
                    <div class="qbdms-listForm">
                        <label class="layui-form-label">姓名</label>
                        <div class="layui-input-block">
                            <input type="text" class="layui-input filter-value" name="Q_userName_SL" placeholder="请输入"/>
                        </div>
                    </div>
                    <div class="qbdms-listForm">
                        <label class="layui-form-label">类别</label>
                        <div class="layui-input-block">
                            <@dicSelect.dic name="Q_kind_SL" nodeKey="sblb" css="layui-input filter-value" />
                        </div>
                    </div>
                </div>
                <div class="selchBtn">
                    <a class="layui-btn layui-btn-sm fillBtn" lay-event="query">
                        <span>查询</span>
                    </a>
                    <div class="layui-btn-group">
                        <button type="button" class="layui-btn layui-btn-sm" lay-event="clears" style="width: 28px;font-size: 12px;padding: 0">
                            <i class="iconfont data-iconcommon_refresh"></i>
                        </button>
                        <button type="button" class="layui-btn layui-btn-sm screenParent" lay-event="screen" style="width: 28px;font-size: 12px;padding: 0">
                            <i class="iconfont data-iconcommon_downarrow screen"></i>
                        </button>
                    </div>
                </div>
            </div>
        </form>
    </div>
</script>
<!-- 右侧工具栏 -->
<script type="text/html" id="wQbdTrustPeopleRightToolsBar">
    {{# if(('${rolealis}'=="bpm_qnzl" && d.allowEdit && '${currentUserId}'==d.createBy) || ('${rolealis}'=="bpm_zlzhzly" &&d.allowEdit )){ }}
    <@f.a alias="xgan_zlxdgzg302" event="edit" css="RightBtn">编辑</@f.a>
    {{#  } }}

    <@f.a alias="xqan_zlxdgzg302" event="particulars" css="RightBtn">详情</@f.a>

    {{# if('${currentUserId}'==d.createBy && d.allowDel){ }}
    <@f.a alias="scan_zlxdgzg302" event="del" css="RightBtn">删除</@f.a>
    {{#  } }}
</script>
<script src="${ctx}/public/component.js" type="text/javascript"></script>
<script src="${ctx}/qbdmsStatic/public/configFile.js"></script>
<script src="${ctx}/layui/layui.js"></script>
<script>
    //一般直接写在一个js文件中
    layui.config({
        base: serverPath.qbdmsPath + staticPath.qbdmsPath //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'table', 'form', 'laydate', 'publicMethods', 'jquery', 'layer', 'common','propsHandle'], function () {
        var table = layui.table;
        var form = layui.form;
        var laydate = layui.laydate;
        var publicMethods = layui.publicMethods;
        var $ = layui.jquery;
        var layer = layui.layer;
        var common = layui.common;
        var propsHandle = layui.propsHandle;
        var defProps = {
                //viewMould: 'form/formDef/view/formDesign/moulds/', // 组件模块 存放文件 *****
                viewMould: 'moulds/', // 组件模块 存放文件 *****
                selectorBtn: '.selectorBtn'
            },
            temQuery = new propsHandle();  // 实例化模板功能部分
        temQuery.initTem({
            selectorBtn: defProps.selectorBtn,
            selectorTemPath: setter.views + defProps.viewMould
        });
        common.tableSort('wQbdTrustPeopleTable');

        var tableH = publicMethods.tabHeight();
        var currentSystemLevel = "${currentSystemLevel}";
        var commonCols = [ //表头
            {type: 'checkbox', fixed: 'left'}
            , {field: 'sn', type: 'numbers', title: '序号', fixed: 'left', minWidth: 90}
            , {field: 'years', title: '年度', sort: false, sortname: 'years', minWidth: 80}
            , {field: 'quarter', title: '季度', sort: false, sortname: 'quarter', minWidth: 80}
            , {field: 'userName', title: '姓名', sort: false, sortname: 'user_name', minWidth: 100}
            , {field: 'company', title: '单位', sort: false, sortname: 'company', minWidth: 140}
            , {field: 'kind', title: '类别', sort: false, sortname: 'kind', minWidth: 90}
            , {field: 'station', title: '岗位', sort: false, sortname: 'station', minWidth: 100}
            , {field: 'job', title: '职务', sort: false, sortname: 'job', minWidth: 100}
            , {field: 'reason', title: '申报理由', sort: false, sortname: 'reason', minWidth: 140}
            , {field: 'flowStatusStr', title: '状态', sort: false, sortname: 'flowStatusStr', minWidth: '120'}];

        var hideCols = [{field: 'remark', title: '备注', sort: false, sortname: 'remark', hide: true}
            , {field: 'sex', title: '性别', sort: false, sortname: 'sex', hide: true}
            , {field: 'awardlevel', title: '等级', sort: false, sortname: 'awardlevel', hide: true}
            , {field: 'userAccount', title: '职工账号', sort: false, sortname: 'user_account', hide: true}
            , {field: 'companyCode', title: '单位编码', sort: false, sortname: 'company_code', hide: true}
            , {field: 'detailDescribe', title: '详细描述', sort: false, sortname: 'detail_describe', hide: true}
            , {field: 'secret', title: '密级', sort: false, sortname: 'secret', hide: true}];

        var manageCols = [{
            minWidth: 200,
            fixed: 'right',
            title: '管理',
            toolbar: '#wQbdTrustPeopleRightToolsBar'
        }];
        var totalCols = [];
        totalCols = totalCols.concat(commonCols).concat(hideCols).concat(manageCols);
        //第一个实例
        table.render({
            elem: '#wQbdTrustPeopleTable'
            , height: tableH
            , url: serverPath.qbdmsPath + '/qbdms/wQbdTrustPeople/list'
            , page: publicMethods.pageFun() //开启分页
            , limit: 20
            , toolbar: '#wQbdTrustPeopleHeaderToolsBar'
            , method: 'post'
            ,defaultToolbar: ['']
            , autoSort: false //是否排序
            , cols: [totalCols],
            done: function () {
                common.tableSelectCon('.ccpui-enterSel .layui-form input', 'a[lay-event=query]', '.ccpui-enterSel');
            }
            ,parseData: function(res){ //res 即为原始返回的数据
                common.parseDataList(res,['reason','level']);
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.msg, //解析提示文本
                    "count": res.count, //解析数据长度
                    "data": res.data //解析数据列表
                };
            }
        });
        //list页面初始化展开按钮tips展示（展开按钮类名）
        publicMethods.tipsAuto('.screen')
        //筛选条件初始化（页面表格的Id，是否初始化（true、false））
        common.initScreenTop('wQbdTrustPeopleTable',true);

        dateReflash()
        function dateReflash() {
            publicMethods.reflashDate({startName: '.start_time1', endName: '.end_time1'});
            publicMethods.reflashDate({startName: '.start_time2', endName: '.end_time2'});
            publicMethods.reflashDate({startName: '.start_time3', endName: '.end_time3'});
            publicMethods.reflashDate({startName: '.start_time4', endName: '.end_time4'});
            //年选择器
            laydate.render({
                elem: '#Q_years_SL'
                , type: 'year'
                , trigger: 'click'
            });
        }

        function reflashQuery(isClear) {
            common.tableConditionRender("wQbdTrustPeopleTable", "wQbdTrustPeopleQueryForm", {where: {}}, isClear, false, 20);
            var researchRoomList = ${researchRoomList}; //问题责任单位
            var researchRoom = function(optionObj, item){
                optionObj.text = item.orgName;
                optionObj.value = item.code;
            };
            common.initDicData("Q_companyCode_S", researchRoomList, "", researchRoom);
        }

        //监听排序事件
        table.on('sort()', function () {
            reflashQuery(false);
        });

        table.on('toolbar(wQbdTrustPeopleTable)', function (obj) {
            var checkStatus = table.checkStatus(obj.config.id);
            var data = checkStatus.data;
            var _this = this;
            switch (obj.event) {
                case 'add':
                    window.location.href = serverPath.qbdmsPath + "/qbdms/wQbdTrustPeople/view/add";
                    break;
                case 'delete':
                    var array = "";
                    for (var i = 0; i < data.length; i++) {
                        array += data[i].id + ",";
                    }
                    delFun(data, array);
                    break;
                case 'export':
                    if (data.length == 0) {
                        layer.confirm(publicMethods.confirmStyle('还没有选择，是否导出全部?'),{title: false,skin: 'confirm-class'}, function (index) {
                            layer.close(index);
                            var url = serverPath.qbdmsPath + '/qbdms/wQbdTrustPeople/exportData';
                            var param = "";
                            $("form[lay-filter='wQbdTrustPeopleQueryForm']").find(".filter-value").each(function (i, value) {
                                param += "&" + this.name + "=" + this.value
                            });
                            open(url, param);
                        });
                    } else {
                        layer.confirm(publicMethods.confirmStyle('确定导出吗?'),{title: false,skin: 'confirm-class'}, function (index) {
                            layer.close(index);
                            var ids = [];
                            for (var i = 0; i < data.length; i++) {
                                ids.push(data[i].id);
                            }
                            var url = serverPath.qbdmsPath + '/qbdms/wQbdTrustPeople/exportData';
                            open(url, "&id=" + ids);
                        });
                    }
                    break;
                case "query":
                    reflashQuery(false);
                    dateReflash();
                    break;
                case "clears":
                    reflashQuery(true);
                    dateReflash();
                    break;
                case "screen":
                    common.initScreenTop('wQbdTrustPeopleTable');
                    dateReflash();
                    form.render();
                    break;
            }
        });

        table.on('tool(wQbdTrustPeopleTable)', function (obj) {
            var data = obj.data, //获得当前行数据
                layEvent = obj.event; //获得 lay-event 对应的值
            switch (layEvent) {
                case "edit":
                    window.location.href = serverPath.qbdmsPath + '/qbdms/wQbdTrustPeople/view/add?id=' + data.id;
                    break;
                case "particulars":
                    window.location.href = serverPath.qbdmsPath + '/qbdms/wQbdTrustPeople/view/particulars?id=' + data.id;
                    break;
                case "del":
                    delFun(data, data.id);
                    break;
            }
        });

        function delFun(data, id) {
            if (data.length === 0) {
                layer.alert(publicMethods.confirmStyle('请先选择一行数据!'),{title: false,skin: 'confirm-class'});
            } else {
                layer.confirm(publicMethods.confirmStyle('确定删除当前数据吗?'),{title: false,skin: 'confirm-class'}, function (index) {
                    layer.close(index);
                    $.ajax({
                        url: serverPath.qbdmsPath + "/qbdms/wQbdTrustPeople/del",
                        type: "post",
                        data: {id: id},
                        dataType: 'json',
                        success: function (data) {
                            layer.alert(publicMethods.confirmStyle(data.msg),{title: false,skin: 'confirm-class'});
                            //执行重载
                            reflashQuery(true);
                            dateReflash();
                        },
                        error: function (XMLHttpRequest, textStatus, errorThrown) {
                            layer.alert(publicMethods.confirmStyle(data.msg),{title: false,skin: 'confirm-class'});
                            //执行重载
                            reflashQuery(true);
                            dateReflash();
                        }
                    })
                })
            }
        }

        window.Initialization = function () {
            dateReflash();
            reflashQuery(true);
        };
        /*刷新时间控件*/
        dateReflash();
        common.tableSort("wQbdTrustPeopleTable", {show: window.Initialization});
        var researchRoomList = ${researchRoomList}; //问题责任单位
        var researchRoom = function(optionObj, item){
            optionObj.text = item.orgName;
            optionObj.value = item.code;
        };
        common.initDicData("Q_companyCode_S", researchRoomList, "", researchRoom);
        form.on('select(companyCode)', function (data) {
            console.log(data.elem[data.elem.selectedIndex].text);
            $("#company").val(data.elem[data.elem.selectedIndex].text);
        });

        function open(url, param) {
            var curUrl = url;
            layer.open({
                type: 2,
                area: ['700px', '520px'],
                title: ['自定义导出', 'font-size:14px;'],
                content: serverPath.qbdmsPath + '/qbdms/wQbdTrustPeople/view/export',
                btnAlign: 'c',
                skin: 'qbdms-layerFormBtn',
                btn: ['确定', '取消'],
                yes: function (index, layero) {
                    url = curUrl;
                    var iframeWin = window["layui-layer-iframe" + index];
                    var data = iframeWin.getData();
                    if (data) {
                        url = url + "?data=" + JSON.stringify(data) + param;
                        window.location.href = encodeURI(url)
                    }
                }
            });
        }
    })
    ;
</script>
</body>
</html>